package com.mt.mall.dao.good;

import com.mt.common.core.web.base.PageDTO;
import com.mt.common.core.web.base.PageResultDTO;
import com.mt.mall.entity.good.SpecificationStock;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Component;
import org.apache.ibatis.annotations.Param;
import java.util.List;

@Mapper
@Component(value = "specificationStockDao")
public interface SpecificationStockDao {

    /**
    * 根据分页参数查询商品销售规格集合
    *
    * @param pageDTO 分页条件
    */
    public List<SpecificationStock> findSpecificationStocks(PageDTO pageDTO);

    /**
    * 查询全部商品销售规格集合
    *
    */
    public List<SpecificationStock> findAllSpecificationStocks();

    /**
    * 查询所有商品销售规格集合(只提取ID 和 Name)
    *
    */
    public List<SpecificationStock> findAllSpecificationStocksWithIdName();

    /**
    * 根据名称查询商品销售规格集合(只提取ID 和 Name)
    *
    * @param specificationStockName 名称
    */
    public List<SpecificationStock> findSpecificationStocksWithIdNameByName(@Param("specificationStockName") String specificationStockName);

    /**
    * 根据ID查询指定的商品销售规格(只提取ID 和 Name)
    *
    * @param specificationStockId Id
    */
    public SpecificationStock findSpecificationStocksWithIdNameById(@Param(" specificationStockId") Long specificationStockId);

    /**
    * 根据分页参数查询商品销售规格集合的数量
    *
    * @param pageDTO 分页条件
    */
    public Long findSpecificationStockTotalCount(PageDTO pageDTO);

    /**
    * 根据ID查询指定的商品销售规格
    *
    * @param specificationStockId Id
    */
    public SpecificationStock findSpecificationStock(@Param("specificationStockId") Long specificationStockId);

    /**
    * 根据ID查询指定的商品销售规格(包含外键)
    *
    * @param specificationStockId Id
    */
    public SpecificationStock findSpecificationStockWithForeignName(@Param("specificationStockId") Long specificationStockId);

    /**
    * 新增商品销售规格
    *
    * @param specificationStock 实体对象
    */
    public Long saveSpecificationStock(SpecificationStock specificationStock);

    /**
    * 更新商品销售规格
    *
    * @param specificationStock 实体对象
    */
    public Long updateSpecificationStock(SpecificationStock specificationStock);

    /**
    * 根据ID删除商品销售规格
    *
    * @param specificationStockId ID
    */
    public Long deleteSpecificationStock(@Param("specificationStockId") Long specificationStockId);

    Long findSpecificationStocksCount(@Param("commodityId") Long commodityId,@Param("specification") String specification);

    List<SpecificationStock> findSpecificationStockByCommodityId(@Param("commodityId")Long commodityId);

    Long decrStock(@Param("commodityId") Long commodityId,@Param("specification") String specification,@Param("count") Integer count);

    Integer getStock(@Param("commodityId") Long commodityId,@Param("specification") String specification);

    int incrStock(@Param("commodityId") Long commodityId,@Param("specification") String specification,@Param("count") Integer count);
}
